/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.persistence.testimonials;

import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.testimonials.Testimonial;
import com.blandware.atleap.persistence.core.PageDAO;
import com.blandware.atleap.persistence.exception.DeleteException;

import java.util.Map;

/**
 * <p>DAO for testimonials</p>
 * <p><a href="TestimonialDAO.java.html"><i>View Source</i></a></p>
 *
 * @author Andrey Grebnev <a href="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
 * @version $Revision: 1.2 $ $Date: 2005/07/29 14:12:21 $
 */
public interface TestimonialDAO extends PageDAO {

	// ~ CRUD methods ================================================================

	/**
	 * Creates new testimonial
	 *
	 * @param testimonial      Value object that represents what item must be created
	 * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the body to
	 *                      corresponding object (resource or page) if it exists
	 * @return ID of created testimonial
	 */
	public Long createTestimonial(Testimonial testimonial, Map linkedObjects);

	/**
	 * Retrieves testimonial with specified ID
	 *
	 * @param testimonialId ID to search by
	 * @return Testimonial with specified ID or null if no testimonial with specified ID exists in database
	 */
	public Testimonial retrieveTestimonial(Long testimonialId);

	/**
	 * Retrieves lite version (with empty 'body' map) of testimonial with specified ID
	 *
	 * @param testimonialId ID to search by
	 * @return Testimonial with specified ID or null if no testimonial with specified ID exists in database
	 */
	public Testimonial retrieveTestimonialLite(Long testimonialId);

	/**
	 * Updates testimonial
	 *
	 * @param testimonial      Testimonial to update
	 * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the body to
	 *                      corresponding object (resource or page) if it exists
	 */
	public void updateTestimonial(Testimonial testimonial, Map linkedObjects);

	/**
	 * Deletes testimonial
	 *
	 * @param testimonial to delete
	 * @throws com.blandware.atleap.persistence.exception.DeleteException
	 *          if testimonial cannot be deleted
	 */
	public void deleteTestimonial(Testimonial testimonial) throws DeleteException;

	// ~ Additional methods ================================================================

	/**
	 * Retrieves filtered/sorted collection of testimonials.
	 *
	 * @param queryInfo Object that contains information about how to filter and sort data
	 * @return Collection of testimonials
	 */
	public PartialCollection listTestimonials(QueryInfo queryInfo);


	/**
	 * Retrieves one random active testimonial
	 *
	 * @return random testimonial or <code>null</code> if there are no active testimonials
	 */
	public Testimonial getRandomTestimonial();

	// ~ Finders ================================================================

	/**
	 * Finds testimonial by URI
	 *
	 * @param testimonialUri URI of testimonial to search by
	 * @return Testimonial or null if nothing was found
	 */
	public Testimonial findTestimonialByUri(String testimonialUri);

}
